﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace Windows8Accelerator.Core.Xaml.Controls
{
    public class SuperDataTemplateSelector : DataTemplateSelector
    {
        private Func<object, DependencyObject, DataTemplate> Selector;
        
        public SuperDataTemplateSelector(Func<object, DependencyObject, DataTemplate> selector)
        {
            Selector = selector;
        }

        protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
        {
            return Selector(item, container) ?? base.SelectTemplateCore(item, container);
        }
    }
}
